package com.ec.edu.common.vo;

import com.ec.edu.common.enums.RoomType;
import lombok.Data;

import java.io.Serializable;

@Data
public class MessageVo<T> implements Serializable {
    private int msgType;
    private int roomType;
    //发送者的用户id
    private String clientId;
    //接受者的用户id
    private String toClientId;
    private String remark;

    //聊天内容
    private T data;

    /**
     * 用于消息的签收
     */
    private String  messageId;

    public MessageVo() {}

    /**
     * 心跳/设备启动
     * @param msgType
     * @param clientId
     * @param data
     */
    public MessageVo(int msgType, String clientId, T data) {
        this.msgType = msgType;
        this.clientId = clientId;
        this.data = data;
    }

    /**
     * 默认私聊
     * @param msgType
     * @param clientId
     * @param toClientId
     * @param data
     */
    public MessageVo(int msgType, String clientId, String toClientId, T data) {
        this.msgType = msgType;
        this.roomType = RoomType.ONE_TO_ONE.getRoomType();
        this.clientId = clientId;
        this.toClientId = toClientId;
        this.data = data;
    }

    /**
     * 私聊，群聊
     * @param msgType
     * @param roomType
     * @param clientId
     * @param toClientId
     * @param data
     */
    public MessageVo(int msgType, int roomType, String clientId, String toClientId, T data) {
        this.msgType = msgType;
        this.roomType = roomType;
        this.clientId = clientId;
        this.toClientId = toClientId;
        this.data = data;
    }
}
